<template>
    <view>
        <view v-if="!isLoad" class="margin-top load loading text-l load-project"></view>
        <block v-else>
            <cmpt-comm-list
                type="meet-list"
                :_params="params_var"
                :search="search || ''"
                :_menus="sortMenus"
                :_items="sortItems"
                route="/teacher/page"
                topBottom="120"
                :isTotalMenu="true"
                placeholder="搜索"
                @list="bindCommListCmpt"
            >
                <!-- List Begin -->
                <view class="main">
                    <view class="list">
                        <view @tap="url" :data-url="'/pages/meet/detail/meet_detail?id=' + item.teacherId" class="item shadow-project" v-for="(item, index) in dataList.list" :key="index">
                            <view class="left">
                                <image class="loading shadow" :lazy-load="true" mode="aspectFill" :src="item.avatar" />
                            </view>

                            <view class="right">
                                <view class="line1">
                                    <view class="title">
                                        <text>{{ item.teacherName }}</text>
                                        <view class="star">
                                            <text class="icon-favorfill text-yellow" v-for="(item, index1) in item.starLevel" :key="index1"></text>
                                            <text class="icon-favor" v-for="(item, index1) in 5 - item.starLevel" :key="index1"></text>
                                        </view>
                                    </view>
                                    <view class="tag-list" v-if="item.tags">
                                        <text v-for="(itm, index1) in item.tags.split(',')" :key="index1">{{ itm }}</text>
                                    </view>
                                </view>
                                <view class="line3">
									<view class="text-grey">
										<text v-for="(course, index) in item.courseName.split(',')" :key="index">
											{{ course }}
										</text>
									</view>
                                    <text class="margin-right-xs margin-left-xs">|</text>
                                    <view>{{ item.leaveDay }}天可预约</view>
                                </view>
                            </view>
                        </view>
                    </view>
                </view>

                <!-- List END -->

                <!-- load begin -->

                <!-- parse <template is="listLoadTpl" :data="skin:'load-project',dataList"/> -->
                <block name="listLoadTpl" v-if="false">
                    <view v-if="!dataList || (dataList && dataList.pageNo < dataList.pageCount)" :class="'load text-grey loading ' + 'text-grey'"></view>
                    <view v-if="dataList && dataList.pageNo > 1 && dataList.pageNo == dataList.pageCount" :class="'load text-grey over ' + 'text-grey'"></view>

                    <block v-if="noHintImg">
                        <image style="height: 500rpx" mode="aspectFit" v-if="dataList && dataList.total == 0" :src="noHintImg" />
                    </block>

                    <block v-else>
                        <view v-if="dataList && dataList.total == 0" :class="'load text-grey ' + 'text-grey'">{{ '暂无记录' ? '暂无记录' : '暂无记录哦~' }}</view>
                    </block>

                    <view style="height: 200rpx"></view>
                </block>
                <!-- load end -->
            </cmpt-comm-list>
        </block>
    </view>
</template>
<script module="tools" lang="wxs" src="@/tpls/wxs/tools.wxs"></script>
<script>
const pageHelper = require('@/utils/helper/page_helper.js');
const ProjectBiz = require('@/utils/biz/project_biz.js');
const MeetBiz = require('@/utils/biz/meet_biz.js');
const BaseBiz = require('@/utils/comm/biz/base_biz.js');
const api = require('@/api/api.js');
export default {
    data() {
        return {
            isLoad: false,
            params_var: null,
            sortMenus: [],
            sortItems: [],
            search: '',

            dataList: {
                list: [],
                pageNo: 0,
                pageCount: 0,
                pageSize: 20,
                total: 0
            },
            list: [],

            itm: {
                title: ''
            },

            noHintImg: '',
            cateId: 1,
            courseList: []
        };
    }
    /**
     * 生命周期函数--监听页面加载
     */,
    onLoad: async function (options) {
        ProjectBiz.initPage(this);
        if (options && options.id) {
            this.courseId = options.id;
			      this.isLoad = true;
            this.params_var = {
                 courseId: this.courseId
            }
            this.courseList =   await api.getCourseList();
            BaseBiz.setCateTitleNew(this.courseList,this.courseId);
            // this.getSearchMenuFun();
        }
		
    },
    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {},
    /**
     * 生命周期函数--监听页面显示
     */
    onShow: async function () {
      uni.setNavigationBarTitle({
        title: "测试"
      })
    },
    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {},
    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {},
    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {},
    methods: {
        url: async function (e) {
            pageHelper.url(e, this);
        },

        bindCommListCmpt: async function (e) {
            pageHelper.commListListener(this, e);
        },

        getSearchMenuFun: function () {
            let sortItem1 = [];
            if (this.courseList.length > 1) {
                sortItem1 = [
                    {
                        label: '全部',
                        type: 'cateId',
                        value: ''
                    }
                ];
                sortItem1 = sortItem1.concat(this.courseList);
            }
            let sortItems = [];
            let sortMenus = sortItem1;
            console.log('sortMenus', sortMenus);
            this.setData({
                sortItems,
                sortMenus
            });
        }
    }
};
</script>
<style>
@import './meet_index.css';
</style>
